<?php
namespace common\models;

use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;

/**
 * Class Menu
 * @package backend\models
 *
 * @property integer $level
 * @property string  $menu_name
 */
class Menu extends ActiveRecord
{
     public static function tableName()
    {
        return 'menu';
    }

    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    # 创建之前
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
                    # 修改之前
                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
                ],
                #设置默认值
                'value' => time()
            ]
        ];
    }

    public function rules()
    {
        return [
            [['parent_code','level','is_show','sort'],'integer'],
            [['menu_name','operation','icon','url'],'string'],
        ];
    }

    public function attributeLabels()
    {
        return [
            'menu_id'=>	'自动增量	' ,
            'menu_name'	=>'权限标志符名称',
            'parent_code'=>'父级code',
            'name_code'	=>'权限标志唯一编码',
            'name_mech'	=>'权限机构分组',
            'operation'=>'操作',
            'url'=>'url',
            'icon'=>'图标',
            'level'=>'层级',
            'is_show'=>'是否显示',
            'sort'=>'排序',
            'created_at'=>'创建时间',
            'updated_at'=>'更新时间',
        ];
    }

}